package com.example.autocode.controller;

import com.example.autocode.AutoCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zhangxin
 * @create 2021/12/23 16:06
 */
@RestController
public class AutoCodeController {
    @Autowired
    private AutoCodeUtil autoCodeUtil;

    @GetMapping(value = "/index/{codeNo}/{inputCharacter}")
    public String index(@PathVariable String codeNo, @PathVariable String inputCharacter) {
        try {
            return autoCodeUtil.generateCode(codeNo, inputCharacter);
        } catch (Exception e) {
            return e.getMessage();
        }
    }
}
